// Copyright (C) 2002-2008 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h

#include "FpsFileList.h"
#include "IrrCompileConfig.h"
#include "irrArray.h"
#include <stdlib.h>

namespace irr
{
namespace io
{


FpsFileList::FpsFileList()
{
	#ifdef _DEBUG
	setDebugName("FpsFileList");
	#endif		
}

void FpsFileList::addEntry(irr::core::stringc name , long size , bool isDir)
{
	FileEntry entry;
			
	entry.Name = name;
	entry.Size = size;
	entry.isDirectory = isDir;

	Files.push_back(entry);
}

u32 FpsFileList::getFileCount() const
{
	return Files.size();
}


const io::path& FpsFileList::getFileName(u32 index) const
{
	io::path p;
	if (index < Files.size())
		return Files[index].Name;
	else
		return p;
}


//! Gets the full name of a file in the list, path included, based on an index.
const c8* FpsFileList::getFullFileName(u32 index)
{
	if (index >= Files.size())
		return 0;

	if (Files[index].FullName.size() < Files[index].Name.size())
	{
		// create full name
		Files[index].FullName = Path;

		if (Path.size() > 3)
			Files[index].FullName.append('/');

		Files[index].FullName.append(Files[index].Name);
	}

	return Files[index].FullName.c_str();
}


bool FpsFileList::isDirectory(u32 index) const
{
	bool ret = false;
	if (index < Files.size())
		ret = Files[index].isDirectory;

	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return ret;
}

} // end namespace irr
} // end namespace io

